#include <iostream>

struct Complex {
    double real;
    double imag;
};

Complex add(const Complex& a, const Complex& b) {
    return {a.real + b.real, a.imag + b.imag};
}

Complex subtract(const Complex& a, const Complex& b) {
    return {a.real - b.real, a.imag - b.imag};
}

Complex multiply(const Complex& a, const Complex& b) {
    return {a.real * b.real - a.imag * b.imag, a.real * b.imag + a.imag * b.real};
}

Complex divide(const Complex& a, const Complex& b) {
    double denominator = b.real * b.real + b.imag * b.imag;
    return {(a.real * b.real + a.imag * b.imag) / denominator, (a.imag * b.real - a.real * b.imag) / denominator};
}

void printComplex(const Complex& c) {
    std::cout << c.real << (c.imag >= 0 ? "+" : "") << c.imag << "i" << std::endl;
}